import * as vscode from 'vscode';
import { DeepseekAPI } from '../deepseekAPI';
import { ChatProvider } from '../chatProvider';
import { ChatHistoryManager } from '../chatHistory';

export class ChatViewProvider implements vscode.WebviewViewProvider {
    private chatProvider: ChatProvider;

    constructor(
        private context: vscode.ExtensionContext,
        private deepseekAPI: DeepseekAPI
    ) {
        // 创建 historyManager 实例
        const historyManager = new ChatHistoryManager(context);
        this.chatProvider = new ChatProvider(context, deepseekAPI, historyManager);
    }

    resolveWebviewView(webviewView: vscode.WebviewView): void | Thenable<void> {
        webviewView.webview.options = {
            enableScripts: true
        };
        this.chatProvider.showInView(webviewView);
    }
} 